library(knitr)
library(dplyr)
library(tidyverse)
library(ggplot2)
library(gridExtra)
library(magrittr)
library(plotly)
library(ggpubr)
library(patchwork)
library(ggmosaic)df <- read.csv("Bidit_Life_data_tracking.csv",header = T, stringsAsFactors = T )mindset <- data.frame(table(df$Mindset.Motivated.Yes.Lazy.No.))
basic_1 <-ggplot(mindset, aes(y=Freq, x=Var1)) +
geom_bar(position="dodge", stat="identity",fill="#FFCC66")+theme_minimal() + geom_text(aes(label = Freq), fontface = "bold", vjust = .5, position = position_dodge(0.9), size = 4)+scale_x_discrete(labels=c("No","Yes"))+xlab("Mindset is Positive")+ylab("Count")+ylim(0,113)
positivity <- data.frame(table(df$Positivity..1.worst.5.best.))
colnames(positivity) <- c("Mood_Rating","Count")
basic_2 <-ggplot(positivity, aes(y=Count, x=Mood_Rating)) +
geom_bar(position="dodge", stat="identity",fill="#FFCC66")+theme_minimal() + geom_text(aes(label = Count), fontface = "bold", vjust = .5, position = position_dodge(0.9), size = 4)+scale_x_discrete(labels=c("Worst","Bad","Moderate","Good","Too Good"))+xlab("Mood Rating")+ylab("Count")+ylim(0,113)
focus <- data.frame(table(df$Focus.Level..1.worst.5.best.))
focus_plot <- ggplot(focus, aes(y=Freq, x=Var1)) +
geom_bar(position="dodge", stat="identity",fill="#FFCC66")+theme_minimal() + geom_text(aes(label = Freq), fontface = "bold", vjust = .5, position = position_dodge(0.9), size = 4)+scale_x_discrete(labels=c("<10mins","10 to 30 mins","30 to 60 mins","60 to 90 mins",">90mins"))+xlab("Focus Time")+ylab("Count")+ylim(0,113)
figure <- ggarrange(
focus_plot, # First row
# Second Row
ggarrange(basic_1, basic_2, ncol = 2, labels = c("Mindset", "Mood")),
nrow = 2,
labels = "Focus Time" # Label of the plot
)
annotate_figure(figure, top = text_grob("Visualizing Mood,Mindset & Focus Time",
color = "red", face = "bold", size = 14),
bottom = text_grob("Data source:Bidit Personal Notion Database", color = "black",
hjust = 1, x = 1, face = "italic", size = 10),
fig.lab = "Figure 1", fig.lab.face = "bold"
)#exercise
exercise <- data.frame(table(df$Exercise))
colnames(exercise) <- c("Exercise","Frequency1")
exercise_plot <- ggplot(exercise, aes(y=Frequency1, x=Exercise)) +
geom_bar(position="dodge", stat="identity",fill="#FF6666")+theme_minimal() + geom_text(aes(label = Frequency1), fontface = "bold", vjust = .5, position = position_dodge(0.9), size = 4)+scale_x_discrete(labels=c("No","Yes"))+xlab("Exercise")+ylab("Count")+ylim(0,113)
#health
health_condition <- data.frame(table(df$Health.Condition..5.Best..1.worst.))
colnames(health_condition) <- c("Health","Frequency2")
health_condition_plot <- ggplot(health_condition, aes(y=Frequency2, x=Health)) +
geom_bar(position="dodge", stat="identity",fill="#FF6666")+theme_minimal() + geom_text(aes(label = Frequency2), fontface = "bold", vjust = .5, position = position_dodge(0.9), size = 4)+scale_x_discrete(labels=c("Extremely Sick","Sick","OK","Good","Healthy,Energetic"))+xlab("Health Condition")+ylab("Count")+ylim(0,113)
#diet calculations
diet <- data.frame(table(df$Diet..1..worst..to.5..best.))
colnames(diet) <- c("Diet","Frequency3")
diet_plot <- ggplot(diet, aes(y=Frequency3, x=Diet)) +
geom_bar(position="dodge", stat="identity",fill="#FF6666")+theme_minimal() + geom_text(aes(label = Frequency3), fontface = "bold", vjust = .5, position = position_dodge(0.9), size = 4)+scale_x_discrete(labels=c("Junk","Unbalanced","OK","Healthly","Balanced"))+xlab("Diet Level")+ylab("Count")+ylim(0,113)
#plotting
figure1 <- ggarrange(
health_condition_plot, # First row with line plot
# Second row with box and dot plots
ggarrange(exercise_plot, diet_plot, ncol = 2, labels = c("Exercise ", "Diet Levels")),
nrow = 2,
labels = "Health" # Label of the line plot
)
annotate_figure(figure1, top = text_grob("Visualizing Health,Diet & Exercise",
color = "red", face = "bold", size = 14),
bottom = text_grob("Data source:Bidit Personal Notion Database", color = "black",
hjust = 1, x = 1, face = "italic", size = 10),
fig.lab = "Figure 2", fig.lab.face = "bold"
)#water consumption calculation
# Creating the month coloumn
df$Month <- as.factor(format(df$On.This.Day,"%b"))
levels(df$Month) <- c(4,5,3,2,1) # Changing factor levels as the ordering is not same
water_consumption <- data.frame(tapply(df$Water.Consumption.in.litre.,df$Month,mean))
df2 <- na.omit(df) # omitting na values in workout time
water_grandmean <- round(mean(df$Water.Consumption.in.litre.),1)
water_consumption_plot <- ggplot(df,aes(x=Month, y=Water.Consumption.in.litre.,fill=Month))+geom_boxplot(alpha=0.3)+theme(legend.position = "none")+scale_fill_brewer(palette = "Dark2")+ylab(" Drinking Water Consumption (in litre)")+geom_hline(aes(yintercept=water_grandmean),colour="#6666CC",lwd=1)+geom_text(aes(0,water_grandmean,label= paste("Average/day",water_grandmean,sep = ":"),vjust=-1,hjust=0),colour="#6666FF")+stat_summary(fun = mean,geom="point",shape=20,size=5,color="red",fill="red")+scale_x_discrete(labels=c("Sep","Oct","Nov","Dec","Jan"))
#Workout calculation
workout_time <- data.frame(tapply(df2$Workout.time.in.mins.,df2$Month,mean))
workout_grandmean <- round(mean(df2$Workout.time.in.mins.),1)
workout_time_plot <- ggplot(df2,aes(x=Month, y=Workout.time.in.mins.,fill=Month))+geom_boxplot(alpha=0.3)+theme(legend.position = "none")+scale_fill_brewer(palette = "Dark2")+ylab("Workout Time (in hour)")+geom_hline(aes(yintercept=workout_grandmean),colour="#6666CC",lwd=1)+geom_text(aes(0,workout_grandmean,label= paste("Average/day",workout_grandmean,sep = ":"),vjust=-1,hjust=0),colour="#6666FF")+stat_summary(fun = mean,geom="point",shape=20,size=5,color="red",fill="red")+scale_x_discrete(labels=c("Sep","Oct","Nov","Dec","Jan"))
#sleep time calculation
sleep_grandmean <- round(mean(df$Sleep.Time.day),1)
sleep_time_plot <- ggplot(df,aes(x=Month, y=Sleep.Time.day,fill=Month))+geom_boxplot(alpha=0.3)+theme(legend.position = "none")+scale_fill_brewer(palette = "Dark2")+ylab("Sleeping Time(in hour)")+geom_hline(aes(yintercept=sleep_grandmean),colour="#6666CC",lwd=1)+geom_text(aes(0,sleep_grandmean,label= paste("Average/day",sleep_grandmean,sep = ":"),vjust=2,hjust=0),colour="#6666FF")+stat_summary(fun = mean,geom="point",shape=20,size=5,color="red",fill="red")+scale_x_discrete(labels=c("Sep","Oct","Nov","Dec","Jan"))
#plotting
figure2 <- ggarrange(
water_consumption_plot, # First row with line plot
# Second row with box and dot plots
ggarrange(workout_time_plot, sleep_time_plot, ncol = 2, labels = c("Workout Time", "Sleeping Time")),
nrow = 2,
labels = " Drinking Water Consumption" # Label of the line plot
)
annotate_figure(figure2, top = text_grob("Visualizing Daily Essential Needs & Activities",
color = "red", face = "bold", size = 14),
bottom = text_grob("Data source:Bidit Personal Notion Database", color = "black",
hjust = 1, x = 1, face = "italic", size = 10),
fig.lab = "Figure 2", fig.lab.face = "bold"
)#meditation
meditation <- data.frame(table(df$Meditation))
colnames(meditation) <- c("Medi","Frequencymed")
meditation_plot <- ggplot(meditation, aes(y=Frequencymed, x=Medi)) +
geom_bar(position="dodge", stat="identity",fill="#CCFF00")+theme_minimal() + geom_text(aes(label = Frequencymed), fontface = "bold", vjust = .5, position = position_dodge(0.9), size = 4)+scale_x_discrete(labels=c("No","Yes"))+xlab("Meditation")+ylab("Count")+ylim(0,113)
#reading
reading <- data.frame(table(df$Reading..Doesn.t.include.Studying.))
colnames(reading) <- c("Reading","Frequencyread")
reading_plot <- ggplot(reading, aes(y=Frequencyread, x=Reading)) +
geom_bar(position="dodge", stat="identity",fill="#CCFF00")+theme_minimal() + geom_text(aes(label = Frequencyread), fontface = "bold", vjust = .5, position = position_dodge(0.9), size = 4)+scale_x_discrete(labels=c("No","Yes"))+xlab("Reading")+ylab("Count")+ylim(0,113)
#morning prayer
prayer <- data.frame(table(df$Morning.Prayer))
colnames(prayer) <- c("Prayer","Frequencypray")
prayer_plot <- ggplot(prayer, aes(y=Frequencypray, x=Prayer)) +
geom_bar(position="dodge", stat="identity",fill="#CCFF00")+theme_minimal() + geom_text(aes(label = Frequencypray), fontface = "bold", vjust = .5, position = position_dodge(0.9), size = 4)+scale_x_discrete(labels=c("No","Yes"))+xlab("Morning Prayer")+ylab("Count")+ylim(0,113)
# Phone time
phone_grandmean <- round(mean(df$Phone.Time.in.mins.),1)
phone_time_plot <- ggplot(df,aes(x=Month, y=Phone.Time.in.mins.,fill=Month))+geom_boxplot(alpha=0.3)+theme(legend.position = "none")+scale_fill_brewer(palette = "Dark2")+ylab("Phone Usage Time(in hour)")+geom_hline(aes(yintercept=phone_grandmean),colour="#6666CC",lwd=1)+geom_text(aes(0,phone_grandmean,label= paste("Average/day",phone_grandmean,sep = ":"),vjust=1,hjust=0),colour="#6666FF")+stat_summary(fun = mean,geom="point",shape=20,size=5,color="red",fill="red")+scale_x_discrete(labels=c("Sep","Oct","Nov","Dec","Jan"))
#plotting
figure3 <- ggarrange(
phone_time_plot, # First row with line plot
# Second row with box and dot plots
ggarrange(meditation_plot, reading_plot, ncol = 2, labels = c("Meditation", "Reading")),
nrow = 2,
labels = " Phone Usage Time" # Label of the line plot
)
annotate_figure(figure3, top = text_grob("Visualizing Daily Essential Needs & Activities",
color = "red", face = "bold", size = 14),
bottom = text_grob("Data source:Bidit Personal Notion Database", color = "black",
hjust = 1, x = 1, face = "italic", size = 10),
fig.lab = "Figure 2", fig.lab.face = "bold"
)q <- table(df$Focus.Level..1.worst.5.best.,df$Meditation)
q_prop <- round(prop.table(q,margin = 2),2)*100
p <- addmargins(q)
rownames(p) <- c("<=10min","10 to 30 mins","30 to 60 mins","60 to 90 mins",">90 mins","Sum")
t <- as.matrix(p)
z <- data.frame(q_prop)
colnames(z) <- c("Focus_Level","Meditation_Status","Count")
fig1 <- plot_ly(
type = 'table',
header = list(
values = c("<b>Focussed Time</b>", "<b>Meditation:No</b>","<b>Meditation:Yes</b>","<b>Sum</b>"),
align = c('left', rep('center', ncol(t))),
line = list(width = 1, color = 'black'),
fill = list(color = 'rgb(235, 100, 230)'),
font = list(family = "Arial", size = 14, color = "white")
),
cells = list(
values = rbind(
rownames(t),
t(as.matrix(unname(t)))
),
align = c('left', rep('center', ncol(t))),
line = list(color = "black", width = 1),
fill = list(color = c('rgb(235, 193, 238)', 'rgba(228, 222, 249, 0.65)')),
font = list(family = "Arial", size = 12, color = c("black"))
))
fig1plot_1 <-ggplot(z, aes(fill=Meditation_Status, y=Count, x=Focus_Level)) +
geom_bar(position="dodge", stat="identity",colour="black")+theme_minimal() + geom_text(aes(label = paste(Count,"%",sep = "")), fontface = "bold", vjust = .5, position = position_dodge(0.9), size = 4)+scale_x_discrete(labels=c("<=10 mins","10 to 30 mins","30 to 60 mins","60 to 90 mins",">90 mins"))+xlab("Focus Time")+ylab("Percentage")+labs(title="MEDITATION & FOCUS TIME",caption = "Data Source:Bidit Personal Notion Database",tag = "Figure-1",fill="Meditation Done")+coord_flip()
plot_1q1 <- table(df$Focus.Level..1.worst.5.best.,df$Exercise)
q1_prop <- round(prop.table(q1,margin = 2),2)*100
p1 <- addmargins(q1)
rownames(p1) <- c("<=10min","10 to 30 mins","30 to 60 mins","60 to 90 mins",">90 mins","Sum")
t1 <- as.matrix(p1)
z1 <- data.frame(q1_prop)
colnames(z1) <- c("Focus_Level","Exercise_Status","Count")
fig3 <- plot_ly(
type = 'table',
header = list(
values = c("<b>Focussed Time</b>", "<b>Exercise:No</b>","<b>Exercise:Yes</b>","<b>Sum</b>"),
align = c('left', rep('center', ncol(t1))),
line = list(width = 1, color = 'black'),
fill = list(color = 'rgb(235, 100, 230)'),
font = list(family = "Arial", size = 14, color = "white")
),
cells = list(
values = rbind(
rownames(t1),
t(as.matrix(unname(t1)))
),
align = c('left', rep('center', ncol(t))),
line = list(color = "black", width = 1),
fill = list(color = c('rgb(235, 193, 238)', 'rgba(228, 222, 249, 0.65)')),
font = list(family = "Arial", size = 12, color = c("black"))
))
fig3plot_2 <-ggplot(z1, aes(fill=Exercise_Status, y=Count, x=Focus_Level)) +
geom_bar(position="dodge", stat="identity",colour="black")+theme_minimal() + geom_text(aes(label = paste(Count,"%",sep = "")), fontface = "bold", vjust = .5, position = position_dodge(0.9), size = 4)+scale_x_discrete(labels=c("<=10 mins","10 to 30 mins","30 to 60 mins","60 to 90 mins",">90 mins"))+xlab("Focus Time")+ylab("Percentage")+labs(title="EXERCISE & FOCUS TIME",caption = "Data Source:Bidit Personal Notion Database",tag = "Figure-2",fill="Exercise Done")+coord_flip()
plot_2q2 <- table(df$Focus.Level..1.worst.5.best.,df$Reading..Doesn.t.include.Studying.)
q2_prop <- round(prop.table(q2,margin = 2),2)*100
p2 <- addmargins(q2)
rownames(p2) <- c("<=10min","10 to 30 mins","30 to 60 mins","60 to 90 mins",">90 mins","Sum")
t2 <- as.matrix(p2)
z2 <- data.frame(q2_prop)
colnames(z2) <- c("Focus_Level","Reading_Status","Count")
fig3 <- plot_ly(
type = 'table',
header = list(
values = c("<b>Focussed Time</b>", "<b>Reading:No</b>","<b>Reading:Yes</b>","<b>Sum</b>"),
align = c('left', rep('center', ncol(t2))),
line = list(width = 1, color = 'black'),
fill = list(color = 'rgb(235, 100, 230)'),
font = list(family = "Arial", size = 14, color = "white")
),
cells = list(
values = rbind(
rownames(t2),
t(as.matrix(unname(t2)))
),
align = c('left', rep('center', ncol(t2))),
line = list(color = "black", width = 1),
fill = list(color = c('rgb(235, 193, 238)', 'rgba(228, 222, 249, 0.65)')),
font = list(family = "Arial", size = 12, color = c("black"))
))
fig3plot_3 <-ggplot(z2, aes(fill=Reading_Status, y=Count, x=Focus_Level)) +
geom_bar(position="dodge", stat="identity",colour="black")+theme_minimal() + geom_text(aes(label = paste(Count,"%",sep = "")), fontface = "bold", vjust = .5, position = position_dodge(0.9), size = 4)+scale_x_discrete(labels=c("<=10 mins","10 to 30 mins","30 to 60 mins","60 to 90 mins",">90 mins"))+xlab("Focus Time")+ylab("Percentage")+labs(title="READING & FOCUS TIME",caption = "Data Source:Bidit Personal Notion Database",tag = "Figure-3",fill="Reading Done")+coord_flip()
plot_3q3 <- table(df$Focus.Level..1.worst.5.best.,df$Mindset.Motivated.Yes.Lazy.No.)
q3_prop <- round(prop.table(q3,margin = 2),2)*100
p3 <- addmargins(q3)
rownames(p3) <- c("<=10min","10 to 30 mins","30 to 60 mins","60 to 90 mins",">90 mins","Sum")
t3 <- as.matrix(p3)
z3 <- data.frame(q3_prop)
colnames(z3) <- c("Focus_Level","Mindset_Status","Count")
fig4 <- plot_ly(
type = 'table',
header = list(
values = c("<b>Focussed Time</b>", "<b>Mindest Positive:No</b>","<b>Mindset Positive:Yes</b>","<b>Sum</b>"),
align = c('left', rep('center', ncol(t2))),
line = list(width = 1, color = 'black'),
fill = list(color = 'rgb(235, 100, 230)'),
font = list(family = "Arial", size = 14, color = "white")
),
cells = list(
values = rbind(
rownames(t3),
t(as.matrix(unname(t3)))
),
align = c('left', rep('center', ncol(t2))),
line = list(color = "black", width = 1),
fill = list(color = c('rgb(235, 193, 238)', 'rgba(228, 222, 249, 0.65)')),
font = list(family = "Arial", size = 12, color = c("black"))
))
fig4plot_4 <-ggplot(z3, aes(fill=Mindset_Status, y=Count, x=Focus_Level)) +
geom_bar(position="dodge", stat="identity",colour="black")+theme_minimal() + geom_text(aes(label = paste(Count,"%",sep = "")), fontface = "bold", vjust = .5, position = position_dodge(0.9), size = 4)+scale_x_discrete(labels=c("<=10 mins","10 to 30 mins","30 to 60 mins","60 to 90 mins",">90 mins"))+xlab("Focus Time")+ylab("Percentage")+labs(title="MINDSET & FOCUS TIME",caption = "Data Source:Bidit Personal Notion Database",tag = "Figure-4",fill="Mindset Positive")+coord_flip()
plot_4q4 <- table(df$Focus.Level..1.worst.5.best.,df$Diet..1..worst..to.5..best.)
q4_prop <- round(prop.table(q4,margin = 2),2)*100
p4 <- addmargins(q4)
rownames(p4) <- c("<=10min","10 to 30 mins","30 to 60 mins","60 to 90 mins",">90 mins","Sum")
t4 <- as.matrix(p4)
z4 <- data.frame(q4_prop)
colnames(z4) <- c("Focus_Level","Diet_Level","Count")
fig5 <- plot_ly(
type = 'table',
header = list(
values = c("<b>Focussed Time</b>", "<b>Diet Levels:1</b>","<b>2</b>","<b>3</b>","<b>4</b>","<b>5</b>","<b>Sum</b>"),
align = c('left', rep('center', ncol(t4))),
line = list(width = 1, color = 'black'),
fill = list(color = 'rgb(235, 100, 230)'),
font = list(family = "Arial", size = 14, color = "white")
),
cells = list(
values = rbind(
rownames(t4),
t(as.matrix(unname(t4)))
),
align = c('left', rep('center', ncol(t4))),
line = list(color = "black", width = 1),
fill = list(color = c('rgb(235, 193, 238)', 'rgba(228, 222, 249, 0.65)')),
font = list(family = "Arial", size = 12, color = c("black"))
))
fig5plot_5 <-ggplot(z4, aes(fill=Diet_Level, y=Count, x=Focus_Level)) +
geom_bar(position="dodge", stat="identity",colour="black")+theme_minimal() + geom_text(aes(label = paste(Count,"%",sep = "")), fontface = "bold", vjust = .5, position = position_dodge(0.9), size = 3)+scale_x_discrete(labels=c("<=10 mins","10 to 30 mins","30 to 60 mins","60 to 90 mins",">90 mins"))+xlab("Focus Time")+ylab("Percentage")+labs(title="DIET & FOCUS TIME",caption = "Data Source:Bidit Personal Notion Database",tag = "Figure-5",fill="Diet Level(1=Worst,5=Best)")+coord_flip()
plot_5ggplot(data = df) +
geom_mosaic(aes(x = product(Diet..1..worst..to.5..best., Focus.Level..1.worst.5.best.), fill = Diet..1..worst..to.5..best.),
na.rm=TRUE) +
labs(x = "Focus Level",
y = "Proportion",
title="Focus Time by Diet Levels",
subtitle = "Left - Right = (1) <10 mins - (5) >90 mins",
caption = "Data Source:Bidit Notion Personal Database",
tag="Fig-5") +
scale_fill_manual(values=c("#440145FF", "#404788FF", "#238A8DFF", "#55C667FF", "#FDE725FF"),
name="Diet Levels",
breaks=c("1", "2", "3", "4", "5"),
labels=c("1-Junk","2-Unbalanced","3-OK","4-Healthly","5-Balanced")) +
theme_minimal() +
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank())q5 <- table(df$Focus.Level..1.worst.5.best.,df$Health.Condition..5.Best..1.worst.)
q5_prop <- round(prop.table(q5,margin = 2),2)*100
p5 <- addmargins(q5)
rownames(p5) <- c("<=10min","10 to 30 mins","30 to 60 mins","60 to 90 mins",">90 mins","Sum")
t5 <- as.matrix(p5)
z5 <- data.frame(q5_prop)
colnames(z5) <- c("Focus_Level","Health_Condition","Count")
fig6 <- plot_ly(
type = 'table',
header = list(
values = c("<b>Focussed Time</b>", "<b>Health Condition:1</b>","<b>2</b>","<b>3</b>","<b>4</b>","<b>5</b>","<b>Sum</b>"),
align = c('left', rep('center', ncol(t5))),
line = list(width = 1, color = 'black'),
fill = list(color = 'rgb(235, 100, 230)'),
font = list(family = "Arial", size = 14, color = "white")
),
cells = list(
values = rbind(
rownames(t5),
t(as.matrix(unname(t5)))
),
align = c('left', rep('center', ncol(t5))),
line = list(color = "black", width = 1),
fill = list(color = c('rgb(235, 193, 238)', 'rgba(228, 222, 249, 0.65)')),
font = list(family = "Arial", size = 12, color = c("black"))
))
fig6plot_6 <-ggplot(z5, aes(fill=Health_Condition, y=Count, x=Focus_Level)) +
geom_bar(position="dodge", stat="identity",colour="black")+theme_minimal() + geom_text(aes(label = paste(Count,"%",sep = "")), fontface = "bold", vjust = .5, position = position_dodge(0.9), size = 3)+scale_x_discrete(labels=c("<=10 mins","10 to 30 mins","30 to 60 mins","60 to 90 mins",">90 mins"))+xlab("Focus Time")+ylab("Percentage")+labs(title="HEALTH CONDITION & FOCUS TIME",caption = "Data Source:Bidit Personal Notion Database",tag = "Figure-6",fill="Health Condition(1=Worst,5=Best)")+coord_flip()
plot_6ggplot(data = df) +
geom_mosaic(aes(x = product(Health.Condition..5.Best..1.worst., Focus.Level..1.worst.5.best.), fill = Health.Condition..5.Best..1.worst.),
na.rm=TRUE) +
labs(x = "Focus Level",
y = "Proportion",
title="Focus Time by Health Condition",
subtitle = "Left - Right = (1) <10 mins - (5) >90 mins",
caption = "Data Source:Bidit Notion Personal Database",
tag="Fig-6") +
scale_fill_manual(values=c("#440145FF", "#404788FF", "#238A8DFF", "#55C667FF", "#FDE725FF"),
name="Health Condition",
breaks=c("1", "2", "3", "4", "5"),
labels=c("1-Extremely Sick","2-Sick","3-OK","4-Good","5-Healthy,Energetic")) +
theme_minimal() +
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank())q6 <- table(df$Focus.Level..1.worst.5.best.,df$Positivity..1.worst.5.best.)
q6_prop <- round(prop.table(q6,margin = 2),2)*100
p6 <- addmargins(q6)
rownames(p6) <- c("<=10min","10 to 30 mins","30 to 60 mins","60 to 90 mins",">90 mins","Sum")
t6 <- as.matrix(p6)
z6 <- data.frame(q6_prop)
colnames(z6) <- c("Focus_Level","Mood","Count")
fig7 <- plot_ly(
type = 'table',
header = list(
values = c("<b>Focussed Time</b>", "<b>Mood Rating:1</b>","<b>2</b>","<b>3</b>","<b>4</b>","<b>5</b>","<b>Sum</b>"),
align = c('left', rep('center', ncol(t5))),
line = list(width = 1, color = 'black'),
fill = list(color = 'rgb(235, 100, 230)'),
font = list(family = "Arial", size = 14, color = "white")
),
cells = list(
values = rbind(
rownames(t6),
t(as.matrix(unname(t6)))
),
align = c('left', rep('center', ncol(t6))),
line = list(color = "black", width = 1),
fill = list(color = c('rgb(235, 193, 238)', 'rgba(228, 222, 249, 0.65)')),
font = list(family = "Arial", size = 12, color = c("black"))
))
fig7ggplot(data = df) +
geom_mosaic(aes(x = product(Positivity..1.worst.5.best., Focus.Level..1.worst.5.best.), fill = Positivity..1.worst.5.best.),
) +
labs(x = "Focus Level",
y = "Proportion",
title="Mood on Focus Time",
subtitle = "Left - Right = (1) <10 mins - (5) >90 mins",
caption = "Data Source:Bidit Notion Personal Database",
tag="Fig-6") +
scale_fill_manual(values=c("#440145FF", "#404788FF", "#238A8DFF", "#55C667FF", "#FDE725FF"),
name="Mood",
breaks=c("1","2","3","4","5"),
labels=c("1-Worst","2-Bad","3-Moderate","4-Good","5-Too Good")) +
theme_minimal() +
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank())water_consumption_focus <- ggplot(df,aes(x=Focus.Level..1.worst.5.best., y=Water.Consumption.in.litre.,fill=Focus.Level..1.worst.5.best.))+geom_boxplot(alpha=0.3)+theme(legend.position = "none")+scale_fill_brewer(palette = "Dark2")+ylab("Water Consumption(in litre)")+xlab("Focus Time")+scale_x_discrete(labels=c("<=10 mins","10 to 30 mins","30 to 60 mins","60 to 90 mins",">90 mins"))+labs(title="Water Consumption on Focus level",caption="Data Source:Bidit Personal Notion Database",subtitle="Figure-7")
water_consumption_focusKendalls Correlation for finding Association
df$Focus.Level..1.worst.5.best. <- as.numeric(df$Focus.Level..1.worst.5.best.)
cor(df$Water.Consumption.in.litre.,df$Focus.Level..1.worst.5.best.,method = "kendall")## [1] 0.4719512
df$Focus.Level..1.worst.5.best. <- as.factor(df$Focus.Level..1.worst.5.best.)
phone_usage <- ggplot(df,aes(x=Focus.Level..1.worst.5.best., y=Phone.Time.in.mins.,fill=Focus.Level..1.worst.5.best.))+geom_boxplot(alpha=0.3)+theme(legend.position = "none")+scale_fill_brewer(palette = "Dark2")+ylab("Phone Usage(in hr)")+xlab("Focus Time")+scale_x_discrete(labels=c("<=10 mins","10 to 30 mins","30 to 60 mins","60 to 90 mins",">90 mins"))+labs(title="Phone Usage Time on Focus level",caption="Data Source:Bidit Personal Notion Database",subtitle="Figure-8")
phone_usageKendalls Correlation for finding Association
df$Focus.Level..1.worst.5.best. <- as.numeric(df$Focus.Level..1.worst.5.best.)
cor(df$Phone.Time.in.mins.,df$Focus.Level..1.worst.5.best.,method = "kendall")## [1] -0.2711844
df$Focus.Level..1.worst.5.best. <- as.factor(df$Focus.Level..1.worst.5.best.)
sleep_time <- ggplot(df,aes(x=Focus.Level..1.worst.5.best., y=Sleep.Time.day,fill=Focus.Level..1.worst.5.best.))+geom_boxplot(alpha=0.3)+theme(legend.position = "none")+scale_fill_brewer(palette = "Dark2")+ylab("Sleep Time(in hr)")+xlab("Focus Time")+scale_x_discrete(labels=c("<=10 mins","10 to 30 mins","30 to 60 mins","60 to 90 mins",">90 mins"))+labs(title="Sleep Time on Focus level",caption="Data Source:Bidit Personal Notion Database",subtitle="Figure-9")
sleep_timeKendalls Correlation for finding Association
df$Focus.Level..1.worst.5.best. <- as.numeric(df$Focus.Level..1.worst.5.best.)
cor(df$Sleep.Time.day,df$Focus.Level..1.worst.5.best.,method = "kendall")## [1] -0.08045435
df$Focus.Level..1.worst.5.best. <- as.factor(df$Focus.Level..1.worst.5.best.)
workout <- ggplot(df,aes(x=Focus.Level..1.worst.5.best., y=Workout.time.in.mins.,fill=Focus.Level..1.worst.5.best.))+geom_boxplot(alpha=0.3)+theme(legend.position = "none")+scale_fill_brewer(palette = "Dark2")+ylab("Workout Time(in hr)")+xlab("Focus Time")+scale_x_discrete(labels=c("<=10 mins","10 to 30 mins","30 to 60 mins","60 to 90 mins",">90 mins"))+labs(title="Workout Time on Focus level",caption="Data Source:Bidit Personal Notion Database",subtitle="Figure-10")
workoutKendalls Correlation for finding Association
df$Focus.Level..1.worst.5.best. <- as.numeric(df$Focus.Level..1.worst.5.best.)
cor(df$Workout.time.in.mins.,df$Focus.Level..1.worst.5.best.,method = "kendall",use = "na.or.complete")## [1] 0.3132672